#pragma once
#include "strategy.h"

// This is a example of a specific stategy that can be implemented
// it uses a functor to sort the targeting priorty
class StrategyPar :
	public Strategy
{
public:
	StrategyPar(void);
	~StrategyPar(void);
	//void setTargets(std::vector<std::string>& the_targets);
	void setTargetsSpecial();
	std::vector<std::string>& getTargetPriority(std::string unit);
};

// functor used to sort targets
struct byDamageToHitPoints
{
	bool operator()(std::string const &a, std::string const &b)
	{
		BWAPI::UnitType A = BWAPI::UnitTypes::getUnitType(a);
		BWAPI::UnitType B = BWAPI::UnitTypes::getUnitType(b);
		int aDamage,bDamage,aGround,aAir,bGround,bAir;
		BWAPI::WeaponType AGWeapon = A.groundWeapon();
		BWAPI::WeaponType AAWeapon = A.airWeapon();
		BWAPI::WeaponType BGWeapon = B.groundWeapon();
		BWAPI::WeaponType BAWeapon = B.airWeapon();
		if(AGWeapon != BWAPI::WeaponTypes::None)
		{
			aGround = AGWeapon.damageAmount();
			if(AGWeapon.targetsAir())
				aAir = aGround;
		}
		if(BGWeapon != BWAPI::WeaponTypes::None)
		{
			bGround = BGWeapon.damageAmount();
			if(BGWeapon.targetsAir())
				bAir = bGround;
		}
		if(AAWeapon != BWAPI::WeaponTypes::None)
		{
			aGround = AAWeapon.damageAmount();
			if(AAWeapon.targetsAir())
				aAir = aGround;
		}
		if(BAWeapon != BWAPI::WeaponTypes::None)
		{
			bGround = BAWeapon.damageAmount();
			if(BAWeapon.targetsAir())
				bAir = bGround;
		}
		if(aGround > aAir)
			aDamage = aGround;
		else
			aDamage = aAir;
		if(bGround > bAir)
			bDamage = bGround;
		else
			bDamage = bAir;
		return aDamage/(A.maxHitPoints()) > bDamage/(B.maxHitPoints());
	}
};
